package com.imooc.exception;

import com.imooc.utils.IMOOCJSONResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.multipart.MaxUploadSizeExceededException;

/**
 * @ClassName: CustomExceptionHandler
 * @Package: com.imooc.exception
 * @Description:
 * @Date: 2021/7/23 10:23
 * @Author: sunzheng@beiming.com
 */
@RestControllerAdvice
public class CustomExceptionHandler {

  // 上传文件超过500kb, 捕获异常  MaxUploadSizeExceededException
  @ExceptionHandler(MaxUploadSizeExceededException.class)
  public IMOOCJSONResult handMaxUploadFile(MaxUploadSizeExceededException ex) {
    return IMOOCJSONResult.errorMsg("文件上传大小不能超过500kb, 请压缩图片或者降低图片质量再上传");
  }

}
